local seven = fk.CreateSkill {

  name = "joy__seven",

  tags = {  },

}



seven:addEffect("active", {
  name = "joy__seven",
  anim_type = "drawcard",
  card_num = 1,
  prompt = "每个类型限一次，你可以将基本牌重铸为锦囊牌，锦囊牌重铸为装备牌，装备牌重铸为基本牌。",
  can_use = function (self, player, card, extra_data)
    local mark = type(player:getMark(seven.name.."-turn")) == "table" and player:getMark(seven.name.."-turn") or {}
    return #mark < 3
  end,
  card_filter = function (self, to_select, selected, selected_targets)
    local mark = type(player:getMark(seven.name.."-turn")) == "table" and player:getMark(seven.name.."-turn") or {}
    return #selected == 0 and not table.contains(mark,Fk:getCardById(to_select).type)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local card = Fk:getCardById(effect.cards[1])
    local typec
    local mark = type(player:getMark(seven.name.."-turn")) == "table" and player:getMark(seven.name.."-turn") or {}
    table.insertIfNeed(mark,card.type)
    room:setPlayerMark(player,seven.name.."-turn",mark)
    if card.type == Card.TypeBasic then
      typec = "trick"
    elseif card.type == Card.TypeTrick then
      typec = "equip"
    elseif card.type == Card.TypeEquip then
      typec = "basic"
    end
    local card_ids = effect.cards
    local who = effect.from
    if type(card_ids) == "number" then
      card_ids = {card_ids}
    end
    local skillName = seven.name
    room:moveCards({
      ids = card_ids,
      from = who.id,
      toArea = Card.DiscardPile,
      skillName = skillName,
      moveReason = fk.ReasonRecast,
      proposer = who.id
    })
    room:sendFootnote(card_ids, {
      type = "##RecastCard",
      from = who.id,
    })
    room:broadcastPlaySound("./audio/system/recast")
    room:sendLog{
      type = skillName == "recast" and "#Recast" or "#RecastBySkill",
      from = who.id,
      card = card_ids,
      arg = skillName,
    }
    if player.dead then return end
    local cards = room:getCardsFromPileByRule(".|.|.|.|.|"..typec,1,"allPiles")
    if #cards > 0 then
      room:moveCards({
        ids = cards,
        to = player.id,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonJustMove,
        proposer = player.id,
        skillName = seven.name,
      })
    end
  end,
})

return seven